# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=pycairo
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-cairo")
pkgver=1.20.0
pkgrel=1
pkgdesc="Python bindings for the cairo graphics library (mingw-w64)"
url="https://pycairo.readthedocs.io"
arch=('any')
license=('LGPL' 'MPL')
depends=("${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-python")
provides=("${MINGW_PACKAGE_PREFIX}-python3-cairo")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-cairo")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-cairo")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
source=(https://github.com/pygobject/${_realname}/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz)
sha256sums=('5695a10cb7f9ae0d01f665b56602a845b0a8cb17e2123bfece10c2e58552468c')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/python setup.py test
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 COPYING* -t "${pkgdir}${MINGW_PREFIX}/share/licenses/python-cairo"
}
